package com.tilas.mapper;

import com.tilas.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface DepMapper {

//    @Results({
//            @Result(column = "create_time",property = "createTime"),
//            @Result(column = "update_time",property = "updateTime")
//    })


    /***
     *  查询所有部门
     */

    @Select("select * from tlias.dept order by update_time desc ")
    List<Dept> findAll();



    /**
     *  根据id删除部门
     * */
    @Delete("delete from tlias.dept where id=#{id}")
    int deleteById(Integer id);



    /**
     *   新增部门
     * */
    @Insert("insert into dept(name, create_time, update_time) VALUE (#{name},#{createTime},#{updateTime})")
    void add(Dept dept);

    /**
     *  根据id查询部门
     * */
    @Select("select * from tlias.dept where id=#{id}")
    Dept findOne(Integer id);

    @Update("update dept set name =#{name},update_time=#{updateTime} where id=#{id};")
    void upDate(Dept dept);
}
